package com.zyit.web;

import com.zyit.entity.T_notice;
import com.zyit.service.Impl.NewsServiceImpl;
import com.zyit.service.NewsService;
import com.zyit.util.Page;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/news")
public class NewsServlet extends HttpServlet {
    private NewsService newsService = new NewsServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       // List<T_notice> t_noticeList = newsService.findAll();
       // req.setAttribute("t_noticeList",t_noticeList);
        String pageNo = req.getParameter("pageNo");
        Integer currPage = 1;
        try {
            currPage = Integer.valueOf(pageNo);
        }catch (NumberFormatException e){
            e.printStackTrace();
        }
        Page<T_notice> t_noticePage = newsService.findByPage(currPage);
        req.setAttribute("t_noticePage",t_noticePage);
        req.getRequestDispatcher("/manager/notice/noticeList.jsp").forward(req,resp);

    }
}
